import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { FlowForm, FlowPage, FlowQuery, FlowOptions } from "./types";
import { LocationQueryValue } from "vue-router";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getFlowPage(
  queryParams: FlowQuery
): AxiosPromise<PageResult<FlowPage[]>> {
  return request({
    url: "/admin/flow/index",
    method: "get",
    params: queryParams,
  });
}

export function getOptions(): AxiosPromise<FlowOptions[]> {
  return request({
    url: "/admin/flow/getOptions",
    method: "get",
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getFlowForm(
  ids: string | LocationQueryValue[]
): AxiosPromise<FlowForm> {
  return request({
    url: "/admin/flow/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addFlow(data: any) {
  return request({
    url: "/admin/flow/add",
    method: "post",
    data: data,
  });
}

export function addFlowUser(data: any) {
  return request({
    url: "/admin/flow/flowUser",
    method: "post",
    data: data,
  });
}

export function getFlowUserForm(ids: string | LocationQueryValue[]): any {
  return request({
    url: "/admin/flow/flowUserForm",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function updateFlow(data: FlowForm) {
  return request({
    url: "/admin/flow/edit",
    method: "put",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteFlow(data: any) {
  return request({
    url: "/admin/flow/del",
    method: "delete",
    data,
  });
}
